# Create your views here.
from rest_framework.views import APIView
from rest_framework.response import Response
from schedulers.models import get_job_run_error,get_job_run_history,get_job_run_next
from schedulers.models import delete_run_history
#任务下次运行时间
class JobNextRunTimeAPIView(APIView):
    authentication_classes = []
    def get(self,request):
        data = get_job_run_next()
        ret = {
            'code':200,
            'status':'success',
            'data':data,
        }

        return Response(ret)

#任务最近运行历史
class JobRunTimeHistory(APIView):
    authentication_classes = []
    def get(self,request):
        data = get_job_run_history()
        ret = {
            'code':200,
            'status':'success',
            'data':data
        }
        return Response(ret)

#任务最近运行错误
class JobRunErrorHistory(APIView):
    authentication_classes = []
    def get(self,request):
        data = get_job_run_error()
        ret = {
            'code': 200,
            'status': 'success',
            'data': data
        }
        return Response(ret)

class DeleteHistoryRunRecordAPI(APIView):
    def get(self,request):
        delete_run_history()
        ret = {
            'code':200,
            'status':'success',
        }
        return Response(ret)